<?php
/**
 * Created by PhpStorm.
 * User: Antique
 * Date: 2021/12/6
 * Time: 下午 08:25
 */
if (!empty($_COOKIE['Token'])) {
    $pd = '0';
    $over_time = $_COOKIE['cookie_expire'];
    $time = date('Y年m月d日 h时i分s秒', $over_time);
} else {
    $pd = '1';
}

?>
<!DOCTYPE html>
<html>
<body id="body1">
<h1>用户中心</h1>
cookie到期时间:<?php echo $time ?>
<form action="look_head_img.php" name="form1" method="post" enctype="multipart/form-data">
    <input type="file" name="head_img" id="ipt1" onchange="imgshow()" value=""/>
    <input type="submit" name="" id="" value="提交头像"/>
    <br/>
</form>
</body>
<img id="img1" src=""/>
<script type="text/javascript" id="">
    var img1_ = document.getElementById('img1');
    var ipt1_ = document.getElementById('ipt1');
    if (<?php echo $pd ?> == '1'
    )
    {
        alert('你还没登陆或者cookie失效');
        window.location.href = 'login.php';
    }

    function imgshow() {
        var files = ipt1_['files'];
        var url = window.URL;
        var imgurl = url.createObjectURL(files[0]);
        img1_.src = imgurl;
        img1_.style.width = '200px';
    }
</script>

</html>
